package com.example.waibao.dao;


import com.example.waibao.entity.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface materialMapper {


    @Insert("insert into building(building_name,img_url,school_id) values(#{building_name},#{img_url},#{school_id})")
    void save_building(String building_name, String img_url, int school_id);

    @Select("select img_url from building where building_name = #{building_name} and school_id = #{school_id}")
    String get_img(String building_name, int school_id);

    @Select("select * from img ")
    List<building> getAllImg();

    @Select("select * from task where school_id = #{school_id}")
    List<task> get_task(int school_id);

//    @Insert("insert into task(type_id,award,require,score,task_name,need,school_id) values(#{type_id},#{award}," +
//            " #{require},#{score},#{task_name},#{need},#{school_id})")
//    void add_a_task(task task);
    @Insert("insert into task(task_type_id,award,`require`,score,task_name,need,school_id,article_id,img_url,speciality_id,weight) values(#{task_type_id},#{award}, #{require}," +
            " #{score},#{task_name},#{need},#{school_id},#{article_id},#{img_url},#{speciality_id},#{weight})")
    void add_a_task(String task_name, String award, String require, int score, String need, int school_id, int task_type_id,
                    int article_id,String img_url,int speciality_id,int weight);
    @Insert("insert into to_task(task_id,the_place,school_id) values(#{task_id},#{the_place},#{school_id})")
    void add_task_place(int task_id, String the_place, int school_id);

    @Insert("insert into school_map(map,modal,scope,legend,school_id) values(#{map}," +
            " #{modal},#{scope},#{legend},#{school_id})")
    void save_map(String map, String modal, String scope, String legend, int school_id);

    @Select("select * from task_type")
    List<task_type> get_task_type();

    @Select("select * from task_type")
    List<task_type> get_task_type1(int i);

    @Insert("insert into school_map(school_id,model,map,scope) values(#{school_id}," +
            " #{model},#{map},#{scope})")
    void save_school_map(Object school_id, Object model, String map,String scope);

//
//    name.get(i),scope.get(i),
//            image.get(i),color.get(i),door.get(i),school_map.get("school_id")
    @Insert("insert into school_map_legend(id,name,scope,image,color,door,school_id,introduce_image,introduce) values(#{id},#{name},#{scope}," +
            " #{image},#{color},#{door},#{school_id},#{introduce_image},#{introduce})")
    void save_school_map_legend(int id,String name, String scope, String image, String color, String door, Object school_id,
    String introduce_image,String introduce);

    @Select("select * from school_map where school_id = #{school_id}")
    school_map get_school_map(int school_id);

    @Select("select * from school_map_legend where school_id = #{school_id}")
    List<school_map_legend> get_school_map_legend(int school_id);

    @Select("select * from article")
    List<article> get_article();

    @Delete("delete from school_map where school_id = #{school_id}")
    void delete_school_map(int school_id);

    @Delete("delete from school_map_legend where school_id = #{school_id}")
    void delete_school_map_legend(int school_id);

    @Delete("delete from task where id = #{id}")
    void delete_task(int id);

    @Update("update task set task_name = #{task_name},award = #{award},`require` = #{require},score = #{score},need = #{need},weight=#{weight}," +
            "task_type_id = #{task_type_id},article_id = #{article_id},img_url = #{img_url},speciality_id = #{speciality_id} where id = #{id}")
    void update_task(int id, String task_name, String award, String require, String score, String need, int task_type_id,
                     int article_id, String img_url,int speciality_id,int weight);

    @Select("select the_place from to_task where task_id = #{task_id}")
    List<String> get_places(int task_id);

    @Delete("delete from to_task where task_id = #{task_id}")
    void delete_task_place(int task_id);

//    @Select("select task_id from to_")
//    String get_task_place2(int task_id, int school_id);
}
